package com.qinxueit.admin.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qinxueit.admin.entity.Sys;
import com.qinxueit.admin.service.SysService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class SysConfig {
    @Autowired
    private SysService service;
    public static SysConfig sysConfig;

    @PostConstruct//在初始化的时候初始化静态对象和它的静态成员变量bean对象，静态存储下来，防止被释放
    public void init() {
        sysConfig = this;
        sysConfig.service = this.service;
    }

    public static Sys getSysVal(){
        Sys valObject = sysConfig.service.getOne(new QueryWrapper<Sys>().eq("sys_key", "title_url"));
        return valObject;
    }
}
